import sys
import os

# 获取当前文件所在目录的绝对路径
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取项目根目录
project_root = os.path.dirname(current_dir)
# 将项目根目录添加到Python路径
sys.path.append(project_root)

# 从包中导入所需模块，这会触发__init__.py
from insightface_modules.face_feature_extractor import FaceFeatureExtractor
import argparse

def main():
    parser = argparse.ArgumentParser(description='提取图片中人脸的特征数据')
    parser.add_argument('--image', required=True, help='输入图片路径')
    parser.add_argument('--output', default='output', help='输出目录')
    parser.add_argument('--visualize', action='store_true', help='可视化结果')
    
    args = parser.parse_args()
    
    # 创建特征提取器实例
    extractor = FaceFeatureExtractor()
    
    # 提取特征
    features = extractor.extract_features(args.image, args.output, args.visualize)
    
    # 打印特征维度
    if features and features[0]['embedding_dimension'] is not None:
        print(f"\n特征维度: {features[0]['embedding_dimension']}")
        print(f"检测到的人脸数量: {len(features)}")
    
    # 返回提取的特征数据
    print(features)
    return features

if __name__ == "__main__":
    main()


